//抓取元素
var div = document.getElementById("time");
var spans = div.getElementsByTagName('span');
//获得年月日时分秒
var future = new Date(2016, 8, 15, 00, 00, 00).getTime();
runTime();
//定时器
setInterval(runTime, 1000);
function runTime(){
	//获得当前时间的毫秒数
	var now = new Date().getTime();
	//获得差值毫秒数
	var disTime = future - now;
	//获得天数
	var day = parseInt(disTime / (1000 * 60 * 60 * 24));
	//刨除天之后 还剩多少毫秒数
	disTime = disTime - day * 1000 * 60 * 60 * 24;
	//获得多少个小时
	var hour = parseInt(disTime / (1000 * 60 * 60));
	disTime = disTime - hour * 1000 * 60 * 60;
	var minitus = parseInt(disTime / (1000 * 60));
	disTime = disTime - minitus * 1000 * 60;
	var seconds = parseInt(disTime / 1000);
	spans[0].innerHTML = addZero(day);
	spans[1].innerHTML = addZero(hour);
	spans[2].innerHTML = addZero(minitus);
	spans[3].innerHTML = addZero(seconds);
}

function addZero(num){
	return num<10? '0'+num : num;
}
